package ink.metoo.auto.fishpi.job

import ink.metoo.auto.fishpi.ClientCaches
import ink.metoo.auto.fishpi.Log
import ink.metoo.auto.fishpi.call.UserCall
import ink.metoo.auto.fishpi.chatroom.ChatRooms

class WatchLivenessJob : RunnableJob {

    override fun run() {
        try {
            val newestLiveness = UserCall.getLiveness() ?: -1.0
            if (newestLiveness != ClientCaches.liveness) {
                ClientCaches.liveness = newestLiveness
                ChatRooms.systemConsole(content = "活跃度变化 ${ClientCaches.liveness}%")
            }
        } catch (e: Exception) {
            Log.error("get liveness fail", e)
        }
    }

}